import request from 'supertest';
import app from './WarehouseReceivingAPI'; // 假设你的 WarehouseReceivingAPI 文件名为 WarehouseReceivingAPI.ts

describe('Warehouse Receiving Functionality Tests', () => {
  it('should complete the full workflow for receiving goods', async () => {
    // Step 1: 创建入库单
    const createResponse = await request(app).post('/warehouse/receiving/create').send({
      supplier: 'Supplier A',
      items: [{ name: 'Item 1', quantity: 10 }]
    });
    expect(createResponse.status).toBe(200);
    expect(createResponse.body.message).toBe('入库单已创建');

    // Step 2: 审核入库单
    const approveResponse = await request(app).post('/warehouse/receiving/approve').send({
      receivingId: '12345'
    });
    expect(approveResponse.status).toBe(200);
    expect(approveResponse.body.message).toBe('入库单已审核');

    // Step 3: 商品验收
    const acceptResponse = await request(app).post('/warehouse/receiving/accept').send({
      receivingId: '12345'
    });
    expect(acceptResponse.status).toBe(200);
    expect(acceptResponse.body.message).toBe('商品已验收');

    // Step 4: 商品上架
    const shelveResponse = await request(app).post('/warehouse/receiving/shelve').send({
      receivingId: '12345',
      location: 'A1'
    });
    expect(shelveResponse.status).toBe(200);
    expect(shelveResponse.body.message).toBe('商品已上架');

    // Step 5: 查询入库记录
    const recordsResponse = await request(app).get('/warehouse/receiving/records').query({
      receivingId: '12345'
    });
    expect(recordsResponse.status).toBe(200);
    expect(recordsResponse.body.message).toBe('入库记录查询成功');
  });
});

import request from 'supertest';
import app from './WarehouseShippingAPI'; // 假设你的 WarehouseShippingAPI 文件名为 WarehouseShippingAPI.ts

describe('Warehouse Shipping Functionality Tests', () => {
  it('should complete the full workflow for shipping goods', async () => {
    // Step 1: 创建出库单
    const createResponse = await request(app).post('/warehouse/shipping/create').send({
      store: 'Store A',
      items: [{ name: 'Item 1', quantity: 5 }]
    });
    expect(createResponse.status).toBe(200);
    expect(createResponse.body.message).toBe('出库单已创建');

    // Step 2: 审核出库单
    const approveResponse = await request(app).post('/warehouse/shipping/approve').send({
      shippingId: '12345'
    });
    expect(approveResponse.status).toBe(200);
    expect(approveResponse.body.message).toBe('出库单已审核');

    // Step 3: 商品拣货
    const pickResponse = await request(app).post('/warehouse/shipping/pick').send({
      shippingId: '12345'
    });
    expect(pickResponse.status).toBe(200);
    expect(pickResponse.body.message).toBe('商品已拣货');

    // Step 4: 商品打包
    const packageResponse = await request(app).post('/warehouse/shipping/package').send({
      shippingId: '12345'
    });
    expect(packageResponse.status).toBe(200);
    expect(packageResponse.body.message).toBe('商品已打包');

    // Step 5: 出库确认
    const confirmResponse = await request(app).post('/warehouse/shipping/confirm').send({
      shippingId: '12345'
    });
    expect(confirmResponse.status).toBe(200);
    expect(confirmResponse.body.message).toBe('商品已出库');
  });
});

import request from 'supertest';
import app from './InventoryCheckAPI'; // 假设你的 InventoryCheckAPI 文件名为 InventoryCheckAPI.ts

describe('Inventory Check Functionality Tests', () => {
  it('should complete the full workflow for inventory check', async () => {
    // Step 1: 创建盘点任务
    const createTaskResponse = await request(app).post('/inventory/check/create-task').send({
      range: 'Warehouse A'
    });
    expect(createTaskResponse.status).toBe(200);
    expect(createTaskResponse.body.message).toBe('盘点任务已创建');

    // Step 2: 执行盘点
    const executeResponse = await request(app).post('/inventory/check/execute').send({
      taskId: '12345'
    });
    expect(executeResponse.status).toBe(200);
    expect(executeResponse.body.message).toBe('盘点已执行');

    // Step 3: 处理盘点差异
    const resolveResponse = await request(app).post('/inventory/check/resolve-difference').send({
      taskId: '12345'
    });
    expect(resolveResponse.status).toBe(200);
    expect(resolveResponse.body.message).toBe('盘点差异已处理');

    // Step 4: 生成盘点报告
    const reportResponse = await request(app).get('/inventory/check/report').query({
      taskId: '12345'
    });
    expect(reportResponse.status).toBe(200);
    expect(reportResponse.body.message).toBe('盘点报告已生成');

    // Step 5: 审核盘点结果
    const approveResponse = await request(app).post('/inventory/check/approve').send({
      taskId: '12345'
    });
    expect(approveResponse.status).toBe(200);
    expect(approveResponse.body.message).toBe('盘点结果已审核');
  });
});

import request from 'supertest';
import app from './InventoryTransferAPI'; // 假设你的 InventoryTransferAPI 文件名为 InventoryTransferAPI.ts

describe('Inventory Transfer Functionality Tests', () => {
  it('should complete the full workflow for inventory transfer', async () => {
    // Step 1: 创建调拨单
    const createResponse = await request(app).post('/inventory/transfer/create').send({
      fromWarehouse: 'Warehouse A',
      toWarehouse: 'Warehouse B',
      items: [{ name: 'Item 1', quantity: 20 }]
    });
    expect(createResponse.status).toBe(200);
    expect(createResponse.body.message).toBe('调拨单已创建');

    // Step 2: 审核调拨单
    const approveResponse = await request(app).post('/inventory/transfer/approve').send({
      transferId: '12345'
    });
    expect(approveResponse.status).toBe(200);
    expect(approveResponse.body.message).toBe('调拨单已审核');

    // Step 3: 调出确认
    const confirmOutResponse = await request(app).post('/inventory/transfer/confirm-out').send({
      transferId: '12345'
    });
    expect(confirmOutResponse.status).toBe(200);
    expect(confirmOutResponse.body.message).toBe('调出已确认');

    // Step 4: 调入确认
    const confirmInResponse = await request(app).post('/inventory/transfer/confirm-in').send({
      transferId: '12345'
    });
    expect(confirmInResponse.status).toBe(200);
    expect(confirmInResponse.body.message).toBe('调入已确认');

    // Step 5: 查询调拨记录
    const recordsResponse = await request(app).get('/inventory/transfer/records').query({
      transferId: '12345'
    });
    expect(recordsResponse.status).toBe(200);
    expect(recordsResponse.body.message).toBe('调拨记录查询成功');
  });
});